﻿<UserControl
    x:Class="HDK.Demo.Pages.Views.GroupedIncrementalTest"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:HDK.Demo.Pages.Views"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:DesignHeight="300"
    d:DesignWidth="400"
    xmlns:hdkui="using:HDK.UI.Controls"
    xmlns:hdkuiс="using:HDK.UI.Converters"
    >
    
    <UserControl.Resources>
        <CollectionViewSource x:Name="feeds" Source="{Binding Data}"/>
        <CollectionViewSource x:Name="groups" Source="{Binding Groups}" IsSourceGrouped="True"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.Row="0">
            <Button Content="Change View"  Click="Button_Click_1" />
            <Button Content="AddNewItem" Command="{Binding AddNewItemCommand}" />
        </StackPanel>
        <SemanticZoom x:Name="sz" Grid.Row="1" ViewChangeStarted="SemanticZoomViewChangeStarted" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
            <SemanticZoom.ZoomedInView>
                <GridView x:Name="gvZoomIn"
                          ItemsSource="{Binding Source={StaticResource groups}}"
                          IncrementalLoadingThreshold="5"
                          IncrementalLoadingTrigger="Edge"
                          DataFetchSize="5" 
                          IsSwipeEnabled="True" 
                          ScrollViewer.IsHorizontalScrollChainingEnabled="False">
                    <GridView.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal" Margin="10,10,0,0" HorizontalAlignment="Left" Background="White">
                                <Image Source="{Binding Image}" Height="60" Width="60" VerticalAlignment="Center" Margin="0,0,10,0"/>
                                <TextBlock TextWrapping="Wrap" Width="200" VerticalAlignment="Center" Text="{Binding}" HorizontalAlignment="Left" FontFamily="Segoe UI" />
                            </StackPanel>
                        </DataTemplate>
                    </GridView.ItemTemplate>
                    <GridView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
                                    <TextBlock Text='{Binding Key}' Foreground="Gray" Margin="5" FontSize="18" FontFamily="Segoe UI Light" />
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                            <GroupStyle.Panel>
                                <ItemsPanelTemplate>
                                    <VariableSizedWrapGrid ItemWidth="175" ItemHeight="175" Orientation="Vertical" Margin="0,0,20,0" MaximumRowsOrColumns="3"/>
                                </ItemsPanelTemplate>
                            </GroupStyle.Panel>
                        </GroupStyle>                    
                    </GridView.GroupStyle>
                    <GridView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                    </GridView.ItemsPanel>
                    <Button Visibility="Collapsed"/>
                </GridView>
            </SemanticZoom.ZoomedInView>

            <SemanticZoom.ZoomedOutView>
                <GridView x:Name="gvZoomOut" ItemsSource="{Binding Path=View.CollectionGroups, Source={StaticResource groups}}"
                          Foreground="White" ScrollViewer.IsHorizontalScrollChainingEnabled="False">
                    <GridView.ItemTemplate>
                        <DataTemplate>
                            <TextBlock
                                Text="{Binding Group.Key}"
                                FontFamily="Segoe UI Light"
                                FontSize="24"
                                Foreground="Black" />
                        </DataTemplate>
                    </GridView.ItemTemplate>
                    <GridView.ItemsPanel>
                        <ItemsPanelTemplate>
                            <WrapGrid ItemWidth="75" ItemHeight="75" MaximumRowsOrColumns="1" VerticalChildrenAlignment="Center" />
                        </ItemsPanelTemplate>
                    </GridView.ItemsPanel>
                    <GridView.ItemContainerStyle>
                        <Style TargetType="GridViewItem">
                            <Setter Property="Margin" Value="4" />
                            <Setter Property="Padding" Value="10" />
                            <Setter Property="BorderBrush" Value="Gray" />
                            <Setter Property="BorderThickness" Value="1" />
                            <Setter Property="HorizontalContentAlignment" Value="Center" />
                            <Setter Property="VerticalContentAlignment" Value="Center" />
                        </Style>
                    </GridView.ItemContainerStyle>
                </GridView>
            </SemanticZoom.ZoomedOutView>
        </SemanticZoom>
    </Grid>
</UserControl>
